<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <button>change color</button>

  <script>
    const btn = document.querySelector('button');
    
    function random(number) {
      return Math.floor(Math.random() * (number + 1));
    }

    btn.ondblclick = function () {
      const rndColor = 'rgb(' + random(255) + ',' + random(255) + ',' + random(255) + ')';
      document.body.style.backgroundColor = rndColor;
    }
    btn.onmouseover = function () {
      const rndColor = 'rgb(' + random(255) + ',' + random(255) + ',' + random(255) + ')';
      document.body.style.backgroundColor = rndColor;
    }
    btn.onmouseout = function () {
      const rndColor = 'rgb(' + random(255) + ',' + random(255) + ',' + random(255) + ')';
      document.body.style.backgroundColor = rndColor;
    }

    window.onkeyup = function () {
      const rndColor = 'rgb(' + random(255) + ',' + random(255) + ',' + random(255) + ')';
      document.body.style.backgroundColor = rndColor;
    }
  </script>
</body>
</html>